﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace P2P_Backup.tools
{
    public static class Crypto
    {
        public static SymmetricAlgorithm getAlgorithm(string passPhrase)
        {
            SymmetricAlgorithm result = Rijndael.Create();
            byte[] salt = new byte[] {  0x7f, 0x05, 0xf6, 0x5c, 0x1b, 0x68, 0xf8,
                                                  0x9d, 0x50, 0x1b, 0xcc, 0xe5, 0xda, 0x49, 0x75 };
            PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, salt);
            result.Key = password.GetBytes(32);
            result.IV = password.GetBytes(16);

            return result;
        }
    }
}
